import request from '@/utils/request'
import qs from 'qs'

/**
 * =====================菜品模块======================
 */

// 获取菜品
export function getTableList(pageNumber, pageSize) {
  return request({
    url: '/food/food/list_rewrite',
    method: 'get',
    params: {
      pageNumber,
      pageSize,
      storeId: sessionStorage.getItem('storeId')
    }
  })
}

/**
 * 获取单个菜品
 */

export function getFoodData(id) {
  return request({
    url: '/food/food/find_one',
    method: 'get',
    params: {
      foodId: id
    }
  })
}

/**
 * 添加菜品
 */
export function addFood(form) {
  return request({
    url: '/food/food/save',
    method: 'post',
    data: qs.stringify(
      form
    )
  })
}

/**
 * 修改菜品
 */
export function editFood(form) {
  return request({
    url: '/food/food/update',
    method: 'post',
    data: qs.stringify(
      form
    )
  })
}

/**
 * 删除菜品
 */
export function deleteFood(foodId) {
  return request({
    url: '/food/food/delete',
    method: 'post',
    data: qs.stringify({
      ids: foodId
    })
  })
}

/**
 * 获取未添加到默认下单的菜品
 */
export function findNotDefaultFood(pageNumber, pageSize) {
  return request({
    url: '/food/food/find_not_default_food',
    method: 'get',
    params: {
      pageNumber,
      pageSize,
      storeId: sessionStorage.getItem('storeId')
    }
  })
}


/**
 * 获取打印区域
 */

export function getPrintArea() {
  return request({
    url: '/print/print_area/select_item_rewrite',
    method: 'get',
    params: {
      storeId: sessionStorage.getItem('storeId')
    }
  })
}


